package com.ohxwj.common.utils;

/**
 * Created by Administrator on 2017/11/29.
 */
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

@Component
public class Consumer {

    @Autowired
    private ProducerTest producer;

    // 使用JmsListener配置消费者监听的队列，其中text是接收到的消息
    @JmsListener(destination = "mytest.queue")
    public void receiveQueue(String text) {
        System.out.println("Consumer收到的报文为:"+text);
        Destination destination = new ActiveMQQueue("receive.queue");

        for(int i=0; i<6; i++){
            producer.sendMessage(destination, "receive is chhliu!!!");
        }

    }
}
